package com.youlai.system.controller;


import com.youlai.system.common.result.Result;
import com.youlai.system.model.form.AttendanceSettingForm;
import com.youlai.system.model.form.EmployForm;
import com.youlai.system.service.IAttendanceSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 只茂瑞
 * @since 2024-05-30
 */
@RestController
@RequestMapping("/api/v1/attendancesetting")
@Tag(name = "15.考勤设置管理接口")
@RequiredArgsConstructor
public class AttendanceSettingController {

    private final IAttendanceSettingService attendanceSettingService;

    @Operation(summary = "根据部门查询考勤设置")
    @GetMapping("/{id}/form")
    public Result<AttendanceSettingForm> getAttendanceSettingForm(
            @Parameter(description = "部门id") @PathVariable Long id
    ) {
        AttendanceSettingForm attendanceSettingForm = attendanceSettingService.getAttendanceSettingForm(id);
        return Result.success(attendanceSettingForm);
    }

    @Operation(summary = "根据部门id保存或修改考勤设置")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdateAttendanceSetting(
            @RequestBody AttendanceSettingForm attendanceSettingForm
    ){
        Integer id = attendanceSettingService.saveOrUpdate(attendanceSettingForm);
        return Result.success(id);
    }


}
